home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1854 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Memory deallocation in C and C++
  5. Date: Sat, 13 Jan 1996 13:54:45 GMT
  6. Organization: Netcom
  7. Message-ID: <30f7b91d.67934144@nntp.ix.netcom.com>
  8. References: <4d7r6p$dvg@newsbf02.news.aol.com>
  9. NNTP-Posting-Host: ix-dc11-30.ix.netcom.com
  10. X-NETCOM-Date: Sat Jan 13  5:54:29 AM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. weatby@aol.com (Weatby) wrote:
  14.  
  15. |>delete() and free() can cause problems on at least some compilers if
  16. |>called with an invalid pointer.
  17. |>
  18. |>It would seem to me that a better idea would be that if the pointer
  19. passed
  20. |>hasn't been allocated by the memory management system, it could just
  21. be
  22. |>ignored, instead of causing a crash as does on my compiler.
  23. |>
  24. |>Or, a return value could be added to indicate a bad status.
  25. |>
  26. |>Any comments/ideas on why these are not done?
  27.  
  28. Cost.  On many (most?) systems it would be very expensive to check if
  29. a pointer had been allocated dynamically.  If the pointer is an auto
  30. variable it is impossible since the pointer could take on any value,
  31. including one that happened to match that of a dynamically allocated
  32. pointer.
  33.  
  34.  
  35. Michael M Rubenstein
  36.